package com.yupi.springbootinit.bizmq;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
public class MyMessageProducer {

    @Resource
    private RabbitTemplate rabbitTemplate;

    /**
     * 发送消息的方法
     *
     * */
    public void sendMessage(String exchange, String routingKey, Object message) {
        // 使用 rabbitTemplate 的 convertAndSend 方法来发送消息到指定的交换机
        rabbitTemplate.convertAndSend(exchange, routingKey, message);
    }
}
